package com.cskaoyan.service;

import com.cskaoyan.bean.MarketUser;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.vo.WxFootPrintVo;
import com.cskaoyan.mapper.MarketFootprintMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : qj
 * @since: 2022/10/14  21:43
 */
@Service
public class WxFootPrintServiceImpl implements WxFootPrintService {

    @Autowired
    MarketFootprintMapper marketFootprintMapper;
    @Override
    public CommonData<WxFootPrintVo> queryFootPrintByTypeLimit(BasePageInfo basePageInfo) {
        PageHelper.startPage(basePageInfo.getPage(), basePageInfo.getLimit());
        MarketUser marketUser = (MarketUser)SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
        Integer userId = marketUser.getId();
        List<WxFootPrintVo> wxCollectVoList = marketFootprintMapper.list(userId);

        PageInfo<WxFootPrintVo> pageInfo = new PageInfo<>(wxCollectVoList);
        CommonData<WxFootPrintVo> commonData = CommonData.data(pageInfo);

        return commonData;
    }

    @Override
    public void deleteById(Integer id) {
        int count = marketFootprintMapper.deleteByPrimaryKey(id);
    }
}
